package com.action;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.entity.UserEntity;
import com.opensymphony.xwork2.ActionSupport;
import com.service.ReportService;



@Namespace("/")
@Results({@Result(name="reload", location="my-first.action", type="redirectAction"), 
	@Result(name="list", location="/consult/list.jsp", type="dispatcher"), 
	@Result(name="tovalidateAmount", location="/bank-account/bank-validateAmount.jsp", type="redirect"), 
	@Result(name="toConsultOnline", location="/consult/consultonline_input.jsp", type="dispatcher"),
	@Result(name="toViewStateHis", location="/bank-account/stateList.jsp", type="dispatcher"), 
	@Result(name="toSelectCity", location="/consult/consult-city.jsp", type="dispatcher")})

public class MyFirstAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	@Autowired
	public ReportService reportService;
	public List<UserEntity> empList;
	public UserEntity user;
	public String aa;
	private String currentPage;
	private String pageMethod;

	
	public Long id;
	public String name;
	public Integer age;
	public String address; 
	
	
	@Actions({
		@Action(value="login",params={"str","这是已经注入的了！"}),
		@Action(value="login2")
	})
	public String list() throws SQLException {
		UserEntity user = new UserEntity();
		user.setId(id);
		user.setAddress(address);
		user.setAge(age);
		user.setName(name);
		empList = reportService.queryUsers(user);
		return "toConsultOnline";
	}
	
	public String getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(String currentPage) {
		this.currentPage = currentPage;
	}

	public String getPageMethod() {
		return pageMethod;
	}

	public void setPageMethod(String pageMethod) {
		this.pageMethod = pageMethod;
	}

	@Action(value="pageList")
	public String queryListPage(){/*
		Map params = new HashMap();
		params.put("id", 123);
	     pager = reportService.queryList(params);
	    //把输出的记录集和pager对象保存到request对象中 
	    //httpServletRequest.setAttribute("PAGER", pager); 
	   return actionMapping.findForward(Constants.SUCCESS); 
		return "list";
	*/
		return null;
		}
	

	public List<UserEntity> getEmpList() {
		return empList;
	}

	public void setEmpList(List<UserEntity> empList) {
		this.empList = empList;
	}

	public String getAa() {
		return aa;
		}

	public UserEntity getUser() {
		return user;
	}

	public void setUser(UserEntity user) {
		this.user = user;
	}

	public void setAa(String aa) {
		this.aa = aa;
	}
}
